<% layout('/layouts/default.html', {title: '固定费用项目查询', libs: ['validate','fileupload','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text('固定费用项目详情')}
                <% if (hasPermi('base:fixedexpense:fixedExpense:edit')){ %>
                <button type="button" class="btn btn-primary" id="editView">${text('编辑单据')}</button>
                <% } %>
            </div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${fixedExpense}" action="${ctx}/base/fixedexpense/fixedExpense/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('项目编号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden path="isNewRecord"/>
							<#form:input path="fixedExpenseId" id="fixedExpenseId" maxlength="64" readonly="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('项目名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="fixedExpenseName" maxlength="100" class="form-control required" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('费用类别')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="expenseType" dictType="expense_type" class="form-control required" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('所属部门')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:treeselect id="dept" title="${text('部门选择')}"
								path="office.officeCode" labelPath="office.officeName"
								url="${ctx}/sys/office/treeData"
								class="" allowClear="true" readonly="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('开票类别')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="invoiceCategory" maxlength="2" class="form-control required" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<h4 class="form-unit">${text('车辆结算信息')}</h4>
				<div class="ml10 mr10">
					<table id="vehicleSettlementInfoDataGrid"></table>
				</div>
				<h4 class="form-unit">${text('计价方式')}</h4>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('计价方式')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="priceMethod" dictType="price_method" class="form-control required" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<h4 class="form-unit">${text('销售价格管理')}</h4>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('标准销售价格')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="salesPrice" class="form-control required number" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('标准销售价格比例')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="salesPriceRatio" maxlength="10" class="form-control required" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="ml10 mr10">
					<table id="customerPriceDataGrid"></table>
				</div>
				<h4 class="form-unit">${text('采购价格管理')}</h4>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('标准采购价格')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="purchasePrice" class="form-control required number" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('标准采购价格比例')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="purchasePriceRatio" maxlength="10" class="form-control required" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="ml10 mr10">
					<table id="supplierPriceDataGrid"></table>
				</div>
				<h4 class="form-unit">${text('阶梯价格')}</h4>
				<div class="ml10 mr10">
					<table id="ladderPriceDataGrid"></table>
				</div>
				<h4 class="form-unit">${text('外币阶梯价格')}</h4>
				<div class="ml10 mr10">
					<table id="currencyLadderPriceDataGrid"></table>
				</div>

				<h4 class="form-unit">${text('财务科目')}</h4>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('应付账款科目')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="apAccount" items="${taccountList}"
								itemLabel="accountName" itemValue="accountId" blankOption="true" class="form-control"  disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('应收账款科目')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="arAccount" items="${taccountList}"
								itemLabel="accountName" itemValue="accountId" blankOption="true" class="form-control" disabled="true"/>

							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('预付账款科目')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="preApAccount" items="${taccountList}"
								itemLabel="accountName" itemValue="accountId" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('预收账款科目')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="preArAccount" items="${taccountList}"
								itemLabel="accountName" itemValue="accountId" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('成本科目')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="costAccount" items="${taccountList}"
								itemLabel="accountName" itemValue="accountId" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('收入科目')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="incomeAccount" items="${taccountList}"
								itemLabel="accountName" itemValue="accountId" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>

				<h4 class="form-unit">${text('附件信息')}</h4>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('附件上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${fixedExpense.id}" bizType="fixedExpense_file"
								uploadType="all" class="" readonly="false" preview="true"/>
							</div>
						</div>
					</div>
				</div>
                <div class="form-unit">${text('系统信息')}</div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="createDate" class="form-control" disabled="true"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <!--<#form:input path="createBy" class="form-control" disabled="true"/>-->
                                <#form:select path="createBy" items="${listUser}" disabled="true"
                                itemLabel="userName" itemValue="userCode"  blankOption="true" class="form-control"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="updateDate" readonly="true" maxlength="20" class="form-control"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <!--<#form:input path="updateBy" readonly="true" maxlength="20" class="form-control"/>-->
                                <#form:select path="updateBy" items="${listUser}" disabled="true"
                                itemLabel="userName" itemValue="userCode"  blankOption="true" class="form-control"/>
                            </div>
                        </div>
                    </div>
                </div>

			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
//初始化外币阶梯价格DataGrid对象
$("#currencyLadderPriceDataGrid").dataGrid({
	data: ${toJson(fixedExpense.currencyLadderPriceList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'currencyLadderPriceId', editable:true, hidden:true},
		{header:'${text("币种")}', name:'currencyId', width:100, 
			editable:true, edittype:'select', editoptions:{'class':'form-control',
				items: $.merge([{dictLabel:'&nbsp;',dictValue:''}], ${@DictUtils.getDictListJson('sys_bizhong')}),
				itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
					$(element).select2().on("change",function(){$(this).resetValid()});
				}
			},formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('sys_bizhong')}, val, '${text("未知")}', true);
			}
		},
		{header:'${text("起始金额")}', name:'startAmount', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("结束金额")}', name:'endAmount', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("销售价格")}', name:'salesPrice', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("采购价格")}', name:'purchasePrice', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("固定费用项目ID")}', name:'fixedExpenseId.fixedExpenseId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', hidden: true}
	],
	
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#currencyLadderPriceDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {currencyLadderPriceId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据
	
	// 编辑表格的提交数据参数
	editGridInputFormListName: 'currencyLadderPriceList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,currencyLadderPriceId,currencyId,startAmount,endAmount,salesPrice,purchasePrice,fixedExpenseId.fixedExpenseId,', // 提交数据列表的属性字段
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
//初始化阶梯价格DataGrid对象
$("#ladderPriceDataGrid").dataGrid({
	data: ${toJson(fixedExpense.ladderPriceList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'ladderPriceId', editable:true, hidden:true},
		{header:'${text("资方")}', name:'supplier.supplierName', index:'supplier.supplierName', width:150, align:"center"},
		{header:'${text("起始金额")}', name:'startAmount', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("结束金额")}', name:'endAmount', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("销售价格")}', name:'salesPrice', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("采购价格")}', name:'purchasePrice', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("操作")}', name:'actions', hidden: true}
	],
	
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#ladderPriceDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {ladderPriceId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据
	
	// 编辑表格的提交数据参数
	editGridInputFormListName: 'ladderPriceList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,ladderPriceId,investorId,startAmount,endAmount,salesPrice,purchasePrice,fixedExpenseId.fixedExpenseId,', // 提交数据列表的属性字段
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
//初始化客户销售价格DataGrid对象
$("#customerPriceDataGrid").dataGrid({
	data: ${toJson(fixedExpense.customerPriceList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'customerPriceId', editable:true, hidden:true},
		{header:'${text("客户")}', name:'customer.customerName', index:'customer.customerName', width:150, align:"center"},
		{header:'${text("销售价格")}', name:'price', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number'}},
		{header:'${text("费用比例")}', name:'ratio', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'10', 'class':'form-control required'}},
		{header:'${text("固定费用项目ID")}', name:'fixedExpenseId.fixedExpenseId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', hidden: true}
	],
	
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#customerPriceDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {customerPriceId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据
	
	// 编辑表格的提交数据参数
	editGridInputFormListName: 'customerPriceList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,customerPriceId,customerId,price,ratio,fixedExpenseId.fixedExpenseId,', // 提交数据列表的属性字段
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
//初始化供应商采购价格DataGrid对象
$("#supplierPriceDataGrid").dataGrid({
	data: ${toJson(fixedExpense.supplierPriceList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'supplierPriceId', editable:true, hidden:true},
		{header:'${text("供应商")}', name:'supplier.supplierName', index:'supplier.supplierName', width:150, align:"center"},
		{header:'${text("采购价格")}', name:'price', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control required number'}},
		{header:'${text("费用比例")}', name:'ratio', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'10', 'class':'form-control'}},
		{header:'${text("固定费用项目ID")}', name:'fixedExpenseId.fixedExpenseId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', hidden: true}
	],
	
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#supplierPriceDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {supplierPriceId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据
	
	// 编辑表格的提交数据参数
	editGridInputFormListName: 'supplierPriceList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,supplierPriceId,supplierId,price,ratio,fixedExpenseId.fixedExpenseId,', // 提交数据列表的属性字段
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
//初始化车辆结算信息DataGrid对象
$("#vehicleSettlementInfoDataGrid").dataGrid({
	data: ${toJson(fixedExpense.vehicleSettlementInfoList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'vehicleSettlementInfoId', editable:true, hidden:true},
		{header:'${text("结算资方")}', name:'supplier.supplierName', index:'supplier.supplierName', width:150, align:"center"},
		{header:'${text("是否资方结算项目")}', name:'ifInvestor', width:100, 
			editable:true, edittype:'select', editoptions:{'class':'form-control',
				items: $.merge([{dictLabel:'&nbsp;',dictValue:''}], ${@DictUtils.getDictListJson('sys_yes_no')}),
				itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
					$(element).select2().on("change",function(){$(this).resetValid()});
				}
			},formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('sys_yes_no')}, val, '${text("未知")}', true);
			}
		},
		{header:'${text("是否客户结算项目")}', name:'ifCustomer', width:100, 
			editable:true, edittype:'select', editoptions:{'class':'form-control',
				items: $.merge([{dictLabel:'&nbsp;',dictValue:''}], ${@DictUtils.getDictListJson('sys_yes_no')}),
				itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
					$(element).select2().on("change",function(){$(this).resetValid()});
				}
			},formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('sys_yes_no')}, val, '${text("未知")}', true);
			}
		},
		{header:'${text("备注")}', name:'remarks', width:150, editable:true, edittype:'textarea', editoptions:{'maxlength':'500', 'class':'form-control', 'rows':'1'}},
		{header:'${text("费用项目ID")}', name:'expenseItemId.fixedExpenseId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', hidden: true}
	],
	
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#vehicleSettlementInfoDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {vehicleSettlementInfoId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据
	
	// 编辑表格的提交数据参数
	editGridInputFormListName: 'vehicleSettlementInfoList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,vehicleSettlementInfoId,investor,ifInvestor,ifCustomer,remarks,expenseItemId.fixedExpenseId,', // 提交数据列表的属性字段
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
$("#editView").click(function () {
    var id = $("#fixedExpenseId").val();
    var URL = '${ctx}/base/fixedexpense/fixedExpense/form?fixedExpenseId=' + id;
    window.location.href =URL;
});
</script>